$('.username').blur(function () {
    username = $('.username').val();
    if (!username.match(/^\w{3,20}@\w{2,6}\.[a-zA-Z\.]{2,6}$/)) {
        $(this).next().show();
        $(this).next().next().hide();
    } else {
        $(this).next().hide();
        $(this).next().next().show();
    }
})
$('.password').blur(function () {
    password = $('.password').val();
    if (!password.match(/^\w{6,12}$/)) {
        $(this).next().show();
    } else {
        $(this).next().hide();
    }
})
$('.pwd').blur(function () {
    password = $('.password').val();
    pwd = $('.pwd').val();
    if (password != pwd) {
        $(this).next().show();
    } else {
        $(this).next().hide();
    }
})
$('.nickname').blur(function () {
    nickname = $('.nickname').val();
    if (!nickname.match(/^\w|[\u4e00-\u9fa5]|\w{4,12}$/)) {
        $(this).next().show();
        $(this).next().next().hide();
    } else {
        $(this).next().hide();
        $(this).next().next().show();
    }
})

$("button").click(function () {
    $.ajax({
        url: "zeng.php",
        type: 'POST',
        data: {"username": username, "password": password, "pwd": pwd, "nickname": nickname},
        success: function (data) {
            if (data == "添加成功！") {
                          alert('注册成功，点击登录');document.location='index.php';
            } else {
                alert("错误");

            }
        }
    });
})


